package com.niit.web.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.niit.bean.QuesReply;
import com.niit.bean.Question;
import com.niit.service.QuesReplyService;
import com.niit.service.QuestionService;
import com.niit.service.impl.QuesReplyServiceImpl;
import com.niit.service.impl.QuestionServiceImpl;

@WebServlet("/ShowQuestionViewController")
public class ShowQuestionViewController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("id");

		QuestionService qs = new QuestionServiceImpl();
		Question q = qs.findByQuesId(id);
		request.setAttribute("question", q);

		QuesReplyService qrs = new QuesReplyServiceImpl();
		List<QuesReply> list = qrs.findByQuesId(id);
		request.setAttribute("list", list);
		request.getRequestDispatcher("/jsp/user/plaza/questionview.jsp")
				.forward(request, response);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}

}
